#include <stdint.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <stdio.h>
#include <pthread.h>

/**
 *
 */
static int fd;
void* calls(void *ptr) {
	printf("1 0\n");
	ioctl(fd, 10, 100);
	printf("1 1\n");
	return NULL;
}

void* calls2(void *ptr) {
	printf("2 0\n");
	ioctl(fd, 11, 100);
	printf("2 1\n");
	return NULL;
}

int main() {
	fd = open("/dev/t01", O_RDWR,O_NONBLOCK);
	if (fd < 0) {
		printf("error open");
		exit(0);
	}

	pthread_t thread;
	pthread_t thread2;
	pthread_create(&thread, NULL, calls, NULL);
	sleep(4);
	pthread_create(&thread2, NULL, calls2, NULL);
	pthread_join(thread, NULL);
	pthread_join(thread2, NULL);
	printf("main exit\n");
	close(fd);
	return EXIT_SUCCESS;
}

